import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate"

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    user: '',
  },
  mutations: {
    //将用户名存储到vuex的state库里
    user(state, username) {
      state.user = username;
    },
    //退出时删除state库里面的用户名
    remuser(state) {
      state.user = ''//直接赋值为空
    }
  },
  actions: {},
  modules: {},
  plugins: [createPersistedState()]

});
